<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>

</head>
<body>
<form class="form-inline definewidth m20" action="" method="get" name="form1" id="myForm">
   <table>
		<tr>
			<td align="right">原密码:</td><td><input type="password" name="password"/></td>
		</tr>
		<tr>
			<td align="right">新密码:</td><td><input type="password" name="newPassword"/></td>
		</tr>
		<tr>
			<td align="right">确认密码:</td><td><input id="reviewPassword" type="password"/></td>
			<td><span id="pwd1msg">*</span></td>
		</tr>
		<tr>
			<td colspan="2" align="center"><br/>
<!--				<input type="submit" value="保存" class="btn btn-primary"/>-->
				<input onclick="submitData()" value="保存" class="btn btn-primary"/>
			</td>
		</tr>
   </table>
</form>
<script>
	function submitData() {
		console.log(document.getElementById("pwd1msg").innerHTML)
		if(document.getElementById("pwd1msg").innerHTML === "输入错误"){
			alert("请保持新密码前后一致")
			return
		}
		$.ajax({
			type: "POST",
			url: "/reviewPassword",
			data: $("#myForm").serialize() + "&_method=PUT",
			dataType: "json",
			success: function (vo) {
				alert(vo.msg);
			}
		})
	}

	console.log(document.form1)
	$("#reviewPassword").keyup(function(){
		console.log(this.value);
		console.log(document.form1.newPassword.value);
		if(this.value==document.form1.newPassword.value &&this.value!=""){
			document.getElementById("pwd1msg").innerHTML="输入正确";
		}else{
			document.getElementById("pwd1msg").innerHTML="输入错误";
		}
	})
</script>
</body>
</html>